//详情切换
$(function(){
    $("[name=product_deta]").each(function(i){
        var y=i+1;
        $(this).click(function(){
            $("[name=product_deta]").attr("class","product_details_btn_no");
            $(this).attr("class","product_details_btn_yes");
            $("[name=product_detas]").hide();
            $("#product_"+y).show();
        })
})
	
	var aWidth=402;
	aOffsetLeft = ($(window).width()/2) - (parseInt(aWidth)/2);
	$(".tishi").css({"left":aOffsetLeft+"px"});
	 $(window).resize(function(){ 
		 
		aOffsetLeft = ($(window).width()/2) - (parseInt(aWidth)/2);
		$(".tishi").css({"left":aOffsetLeft+"px"});
	});
	 
	
    //针对ie6的z-index调整
	if($.browser.msie && $.browser.version=="6.0") {
				$(".head").css({"z-index":"5"});
		} 
		
	if($.browser.msie && $.browser.version=="7.0") {
				$(".head").css({"z-index":"5"});
		}
		
	//二维码
	$("[name=two_code]").mouseout(function(){
		$(".foot_two_code").hide();									
	}).mouseover(function(){
		$(".foot_two_code").show();				
	})
	
	$(".foot_two_code").mouseout(function(){
		$(".foot_two_code").hide();									
	}).mouseover(function(){
		$(".foot_two_code").show();				
	})
	//广告页面
	$(".activity_img").each(function(){
		if($(this).find("img").attr("src").length==0){
			$(this).parent().hide();
		}
	});
}) 
     
//点击弹出登录栏
function login_a(){
            $aheight = $(document).height(); 
			$awidth = $(document).width(); 

			$docu =  "<div id=\"bg\" style=\"opacity:0.7!important;filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=70)!important;height:"+	$aheight+"px;width:100%;max-width:120000px;position:absolute;left:0px;top:0px;background:#000;z-index:4;min-width:1200px;\"></div>";
			$("body").append($docu);
			$("#bg").show();		
 			var Widths = 569; 
			var Heights=380;
			aOffsetLeft = ($(window).width()/2) - (parseInt(Widths)/2);   
			aOffsetTop = ($(window).height()/2) - (parseInt(Heights)/2); 
			if ($.browser.msie && ($.browser.version == "6.0") ) { //ie6
				$(".login_register_main").css({position:"absolute", top:$(window).scrollTop()+"px","left":aOffsetLeft+"px"});
			}else{
				$(".login_register_main").css({"left":aOffsetLeft+"px","top":aOffsetTop+"px"});
			}
			 $(window).resize(function(){
				aOffsetLeft = ($(window).width()/2) - (parseInt(Widths)/2);
				aOffsetTop = ($(window).height()/2) - (parseInt(Heights)/2); 

				$(".login_register_main").css({"left":aOffsetLeft+"px","top":aOffsetTop+"px"});
			});
	 		$("#login_register_main").show();
			$("[name=login_register_name]").hide();
			$("#login_main").show();
			$("#image_captcha").click();
			if ($.browser.msie && ($.browser.version == "6.0") && !$.support.style) { //ie6
					 $("#bg").remove(); 
					$(".login_register_main").css({"top":  $(document).scrollTop + 150 + "px" });
			} 
			if($.browser.msie && $.browser.version=="7.0") {
				 $("#bg").remove(); 
			}  
		$(function(){
			$("[name=Dsname]").click(function(){
				$("#login_register_main").hide();
				$("#bg").remove();			  
			})		   
		})			
}
//点击弹出注册栏
function register_a(){
  			$aheight = $(document).height(); 
			$awidth = $(document).width(); 
			$docu =  "<div id=\"bg\" style=\"opacity:0.7!important;filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=70)!important;height:"+	$aheight+"px;width:100%;max-width:120000px;position:absolute;left:0px;top:0px;background:#000;z-index:4;min-width:1200px;\"></div>";
			$("body").append($docu);
			$("#bg").show();		
 			var Widths = 569; 
			var Heights=380;
			aOffsetLeft = ($(window).width()/2) - (parseInt(Widths)/2);   
			aOffsetTop = ($(window).height()/2) - (parseInt(Heights)/2); 
			if ($.browser.msie && ($.browser.version == "6.0") ) { //ie6
				$(".login_register_main").css({position:"absolute", top:$(window).scrollTop()+"px","left":aOffsetLeft+"px"});
			}else{
				$(".login_register_main").css({"left":aOffsetLeft+"px","top":aOffsetTop+"px"});
			}
			 $(window).resize(function(){
				aOffsetLeft = ($(window).width()/2) - (parseInt(Widths)/2);
				aOffsetTop = ($(window).height()/2) - (parseInt(Heights)/2); 
				$(".login_register_main").css({"left":aOffsetLeft+"px","top":aOffsetTop+"px"});
			});
	 		$("#login_register_main").show();
			$("[name=login_register_name]").hide();
			$("#register_main").show();
			if ($.browser.msie && ($.browser.version == "6.0") && !$.support.style) { //ie6
					 $("#bg").remove(); 
			} 
			if($.browser.msie && $.browser.version=="7.0") {
				 $("#bg").remove(); 
			}  
}
//关闭登录注册框
$(function(){
	$("[name=Dsname]").click(function(){
		$("#login_register_main").hide();
		$("#bg").remove();			  
	})		   
})			
//点击弹出找回密码框
function findpass(){
	$("[name=login_register_name]").hide();
	$(".findpass_main").show();
	$('#retrieve_form')[0].reset();
	$("#image_captcha2").click();
}
//登录注册交换。
function loginchange(){
	     $("[name=login_register_name]").hide();
		 $("#login_main").show();
		 $("#image_captcha").click();
}

function registerchange(){
	     $("[name=login_register_name]").hide();
		 $("#register_main").show();
}

//提示窗口取消
function tishi_main_close(){
	$(".tishi").hide();
	$("#bg").remove();
}
//导航

$(document).ready(function(){
    var topMain=$("[name=headtopName]").height();//是头部的高度加头部与nav导航之间的距离
    var abc=$("[name=nimicar]").height();
    $(window).scroll(function(){
        $("[name=kefu]").css("margin-top", $(window).scrollTop()+$(window).height()-120 +"px");			  
        if ($(window).scrollTop()>topMain){//如果滚动条顶部的距离大于topMain则就nav导航就添加类.copy_nav，否则就移除
            $("[name=nav]").css({"position":"fixed","top":0+"px"});
            $("[name=dw_nav]").css({"position":"fixed","top":0+"px"});
			if ($.browser.msie && ($.browser.version == "6.0") && !$.support.style) { //ie6
                        $("[name=nav]").removeClass("copy_nav");
                        $("[name=dw_nav]").removeClass("dw_copy_nav");
						 $("[name=nav]").css({"display":"none"});
						 $("#login_register_main").css( {top: $(document).scrollTop()+"px"} );
			}if($.browser.msie && $.browser.version=="7.0") {
				   		 $("[name=nav]").removeClass("copy_nav");
                        $("[name=dw_nav]").removeClass("dw_copy_nav");
						 $("[name=nav]").css({"display":"none"});
						 $("[name=dw_nav]").css({"display":"none"});
			} 
			
        }else{
			$("[name=nav]").css({"display":"block"});
            $("[name=nav]").css({"position":""});
			$("[name=dw_nav]").css({"display":""});
            $("[name=dw_nav]").css({"position":"","top":100+"px"});
        }
    });
})

 
//导航效果
$(function(){
	$("[name=nav_name]").mouseover(function(){      
		$("[name=nav_name]").attr("class","nav_lanmu");
		$(this).attr("class","nav_lanmu_yes");
		$("[name=nav_xiala]").hide();
		$(this).children().show();
	}).mouseout(function(){
        $("[name=nav_name]").attr("class","nav_lanmu");		
		$("[name=nav_xiala]").hide();
        })	
       $("[name=nav_user_center]").mouseover(function(){  //用户中心
          $(this).attr("class","nav_main_user_yes");								
    }).mouseout(function(){
          $(this).attr("class","nav_main_user");		
     })
	
	 
	$("[name=nav_car]").mouseover(function(){     //购物车
		$(this).css({'background-image':'url(themes/default/images/shoppingCar_2.jpg)'});
		$("[name=shopping_Car]").show();
	})
	$(".nav_main_shoppingCar").mouseleave(function(){
		$(this).css({'background-image':'url(themes/default/images/shoppingCart.jpg)'});
		$("[name=shopping_Car]").hide();										
	})
})




//用户中心收缩
$(function(){ 

        $("[name=user_center]").click(function(){
            var aa=$(this).parent().height();
            var s=(parseInt(aa)); 
            if(s>30){
            $(this).parent().children().hide();
            $(this).attr("class","users_left_cont_txt_yes");
            $(this).show();
            }else {
            $(this).parent().children().show();
            $(this).attr("class","users_left_cont_txt");
            }
            
        })
})
 
//无缝滚动
var pause=false; 
var scrollTimeId=null; 
var container=null; 
var lineHeight=null; 
var speed=0; 

var delay=0; 
simpleScroll=function(container1,lineHeight1,speed1,delay1){ 
container=document.getElementById(container1); 
lineHeight=lineHeight1; 
speed=speed1; 
delay=delay1; 
//滚动效果 
scrollexc=function(){ 
if(pause) return ; 
container.scrollTop+=2; 
var lh=lineHeight||container.getElementsByTagName('li')[0].offsetHeight; 
if(container.scrollTop%lh<=1){ 
clearInterval(scrollTimeId); 

fire(); 
container.scrollTop=0; 
setTimeout(start,delay*1000); 
} 
}; 
//开始滚动 
start=function(){ 
var lh=lineHeight||container.getElementsByTagName('li')[0].offsetHeight; 
if (container.scrollHeight - container.offsetHeight >= lh) 
scrollTimeId = setInterval(scrollexc, speed); 
}; 
//把子节点树中的第一个移动到最后 
fire=function(){ 
container.appendChild(container.getElementsByTagName('li')[0]); 
}; 
container.onmouseover=function(){pause=true;}; 
container.onmouseout=function(){pause=false;}; 
setTimeout(start,delay*1000); 
};